package wiki.liven.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import wiki.liven.pojo.bean.User;
import wiki.liven.mapper.UserMapper;
import wiki.liven.service.IUserService;

import java.util.List;
import java.util.stream.Stream;

/**
 * Created by qiangjun on 2017/2/28.
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements IUserService{

    private final Logger logger = LoggerFactory.getLogger(UserServiceImpl.class);

    @Autowired
    private UserMapper mapper;


    /**
     * 登录后台服务
     *
     * @param userName 用户名称
     * @param password 用户密码
     * @return true 登录成功 false 登录失败
     */
    @Override
    public Boolean loginSystem(String userName, String password) {
        Boolean isLogIn = false;
        List<User> users = mapper.selectList(new EntityWrapper<User>()
                                    .eq("username",userName)
                                    .eq("password",password));
        if (null!=users&&users.size()>0) {
            isLogIn = true;
        }
        return isLogIn;
    }
}
